home *** CD-ROM | disk | FTP | other *** search
/ Acorn User: China / Acorn User China CD-ROM (UK) (Disc B) / Acorn User China CD-ROM (UK) (Disc B).bin / BARNET / ARMLINUX / MAIL / 9805 / text0174.txt < prev    next >
Encoding:
Text File  |  1998-06-02  |  2.3 KB  |  86 lines

  1. > I disagree, and believe that it is a good idea to give an error for
  2. > such redeclarations.
  3.  
  4. That defeats the explicit purpose of the feature.
  5.  
  6. > As far as I can tell, you are complaining because it is not possible
  7. > to do:
  8. > typedef union
  9. >   {
  10. >     union wait *__uptr;
  11. >     int *__iptr;
  12. >   } __WAIT_STATUS __attribute__ ((__transparent_union__));
  13. > /* Declaration */
  14. > extern __pid_t __wait __P ((__WAIT_STATUS __stat_loc));
  15. > /* Definition */
  16. > __pid_t
  17. > __wait (int *__stat_loc)
  18. > /* GCC complains about differing types in __wait's signature */
  19. > {
  20. >   /* some expression involving an int *. */
  21. >   return *__stat_loc = 0;
  22. > }
  23.  
  24. I don't care about that per se.  But it *must* be possible to do:
  25.  
  26.     #include <sys/wait.h>
  27.     pid_t wait(int *);
  28.  
  29. and it is highly desireable that it work for a prototype using `union wait *'
  30. too.
  31.  
  32.  
  33. > Now, I suggest that the above sequence of code is in bad style.
  34.  
  35. There is no question about that.  It really doesn't matter to me what
  36. machinations are required in the wait.h decls or in the definitions of the
  37. wait functions.  
  38.  
  39. But redeclarations with prototypes must be allowed; that is the whole point
  40. of this ridiculous kludge.
  41.  
  42. > But, that's only half the story (otherwise, there would be no reason
  43. > to use a transparent union at all).  The macros I define are fine for
  44. > smart implementors of wait, but what about naive users of wait?
  45. > The transparent_union allows them to do:
  46. > {
  47. >   union wait wu;
  48. >   int wi;
  49. >   float wf;
  50. >   wait (&wu);
  51. >   wait (&wi);
  52. >   wait (&wf);
  53. > }
  54. > causing GCC to warn about typecasts only on the last `wait' call, even
  55. > though to the naked eye it appears as if at least one of the other two
  56. > `wait' calls needs a typecast.
  57. > I believe that this behaviour is exactly the intention of the original
  58. > `transparent_union' flag, and that allowing different function
  59. > prototypes is both confusing and unnecessary, and therefore
  60. > undesirable.
  61.  
  62. I happen to know, being the original instigator of the functionality that
  63. became transparent_union.  That is only half of the job originally intended.
  64. The other half is that naive wait users can do:
  65.  
  66.     #include <sys/wait.h>
  67.     ...
  68.     {
  69.       extern pid_t wait(int *);
  70.       int wi;
  71.       float wf;
  72.       wait(&wi);
  73.       wait(&wf);
  74.     }
  75.  
  76. and the only type error should be the last wait call, just as if the
  77. original decl were `pid_t wait(int *);'.
  78.  
  79.